﻿using Furion.DatabaseAccessor;
using JQData.Core.DbModel;
using JQData.Core.TushareSDK.Models;
using Mapster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JQData.Core
{
    public class Mapper : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<StockBaseResult, StockBasic>()
                .Map(dest => dest.ListingStatus, src => MapListingStatus(src.ListingStatus));
        }

        private ListingStatus MapListingStatus(string listingStatus)
        {
            return listingStatus switch
            {
                "L" => ListingStatus.上市,
                "D" => ListingStatus.退市,
                "P" => ListingStatus.暂停上市,
                _ => throw new NotSupportedException()
            };
        }
    }
}
